
#ifndef FIBHEAP_HEADER

#define FIBHEAP_HEADER

#include "dlinkedlists.h"

typedef struct struct_fibnode fibNode;
struct struct_fibnode {
    int id;
    double key;
    DoublyLinkedNode *lnode;
    
    DoublyLinkedList *child;
    fibNode *parent;
    int degree;
    int mark;
};

struct struct_fibheap{
    fibNode *minNode;
    int n;
    DoublyLinkedList *rootlist;
} typedef fibHeap;



fibHeap* make_fibheap();
int free_fibheap(fibHeap *h);
fibNode* make_fibnode(double key, unsigned int id);
void free_fibnode(fibNode *node);
double fibheap_minimum(fibHeap *h);
void fibheap_link(fibHeap *h, fibNode *y, fibNode *x);
void fibheap_consolidate(fibHeap *h);
void fibheap_insert(fibHeap *h, fibNode *x);
fibNode *fibheap_extractmin(fibHeap *h);
void fibheap_decreasekey(fibHeap *h, fibNode *x, double k);
void fibheap_cut(fibHeap *h, fibNode *x, fibNode *y);
void fibheap_cascadingcut(fibHeap *h, fibNode *y);
void fibheap_debug(fibHeap *h);

#endif
